/*
 * @Description:
 * @Version: 1.668
 * @Autor: 地虎降天龙
 * @Date: 2025-04-01 09:52:42
 * @LastEditors: 地虎降天龙
 * @LastEditTime: 2025-04-02 11:41:51
 */
import { initGlobalState } from 'qiankun'
import { Message } from 'element-ui'

const state = {
  message: '初始化消息',
  curType: '',
  mouseInState: false
}

export const initglobalstate = () => {
  // 初始化 state
  const actions = initGlobalState(state)
  actions.onGlobalStateChange((state, prev) => {
    console.log('主应用监听GlobalState状态更变', state, prev)
    if (state.curType === 'mouseIn') {
      const ms = {
        message: state.mouseInState
          ? '主应用监听子应用:鼠标移入'
          : '主应用监听子应用:鼠标移出',
        type: state.mouseInState ? 'warning' : 'success',
        duration: 2000
      }
      Message(ms)
    }
  })
  window.qiankunActions = actions
}
// actions.setGlobalState(state)
// actions.offGlobalStateChange()
